package fx.mine.active.util;

import cn.hutool.core.io.FileUtil;
import com.alibaba.fastjson.JSON;
import lombok.Data;

import java.nio.charset.StandardCharsets;
import java.util.List;

public abstract class GlobalConfigUtils {

    public static final ConfigBean CONFIG_BEAN;
    static {
        String configStr =
                FileUtil.readString(
                        GlobalConfigUtils.class.getResource("/globalConfig.json").getFile(),
                        StandardCharsets.UTF_8
                );
        CONFIG_BEAN = JSON.parseObject(configStr, ConfigBean.class);
    }

    @Data
    public static class ConfigBean {
        private boolean autoSlide;
        private List<SideBarNavItem> sideBarNavItems;
        private Mock mock;

        @Data
        public static class Mock {
            private boolean useMock;
            private String cookies;
        }
        @Data
        public static class SideBarNavItem {
            private Blog blog;

            @Data
            public static class Blog {
                private boolean enable;
            }
        }
    }

    public static void main(String[] args) {
        boolean autoSlide = CONFIG_BEAN.isAutoSlide();
        System.out.println(autoSlide);
    }
}
